//
//  HCRegisterSecondViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/2/14.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCRegisterSecondViewController.h"

#import "HCRegisterSecondView.h"

@interface HCRegisterSecondViewController () <HCRegisterSecondViewDelegate>

@end

@implementation HCRegisterSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.textTitle = @"注册";
    
    self.dataRequest.delegate = self;
    
    HCRegisterSecondView *view = [[HCRegisterSecondView alloc] initWithFrame:CGRectMake(0, 0, self.self.centerView.frame.size.width, self.centerView.frame.size.height)];
    view.delegate = self;
    [self.centerView addSubview:view];
    
    // Do any additional setup after loading the view from its nib.
}

-(void)hc_registerData:(NSString *)username password:(NSString *)pwd address:(NSString *)add phone:(NSString *)phone realName:(NSString *)name sex:(NSString *)sex bir:(NSString *)bir idcard:(NSString *)idcard chi_name:(NSString *)chi_name chi_sex:(NSString *)chi_sex chi_bir:(NSString *)chi_bir {
    
    [WZNetWorkStatusManager show:self.centerView type:WZNetWorkStatusLoadingWithImage msg:YBKLoadingText subMsg:nil offsetY:(self.centerView.frame.size.height - YBKAdaptiveH(120))/2.0 failClickBlock:nil];
    
    [self.dataRequest postHC_Register:phone user_bir:bir user_address:add user_idcard:idcard child_name:chi_name child_bir:chi_bir child_sex:chi_sex user_sex:sex password:pwd user_par_name:name user_name:username];
}

-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    [WZNetWorkStatusManager dismiss:self.centerView];
    NSLog(@"注册数据:%@",dictionary);
    
    if ([dictionary[@"stat"] integerValue] == 200) {
        [self.navigationController popToRootViewControllerAnimated:YES];
        [XHToast showBottomWithText:@"注册成功，请登录"];
    }else {
        [XHToast showBottomWithText:@"注册失败，请稍后重试"];
    }
    
}

-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {
    [WZNetWorkStatusManager dismiss:self.centerView];
    NSLog(@"注册数据请求失败");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
